import { userProfilesAPI } from "../../../request/api";
export default {
    namespaced: true,
    state: {
        cartTotal: 0,
        userInfo: {
            headImg: require("../../assets/img/userImg.f8bbec5e.png"),
            nickName: "--",
            coin: "--"
        },
    },
    mutations: {
        updateUserInfo(state, payload) {
            state.cartTotal = payload.cartTotal;
            state.userInfo = payload.userInfo;
        },
        infouserInfo(state) {
            state.cartTotal = 0;
            state.userInfo = {
                headImg: require("../../assets/img/userImg.f8bbec5e.png"),
                nickName: "--",
                coin: "--"
            }
        }

    },
    actions: {
        asyncUpdateUserInfo(context) {
            userProfilesAPI().then(res => {
                // 更新购物车数量cartTotal和用户信息userInfo
                context.commit("updateUserInfo", res.data)
            })
        }
    },
}